package cc.bailongma.me.adapter;


import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import cc.bailongma.me.R;

public class CalendarAdapter extends BaseAdapter{
	private Activity activity;
	private String[] date;
		public CalendarAdapter(FragmentActivity activity,
			String[] date) {
		this.date=date;
		this.activity=activity;
	}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return date.length;
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return date[position];
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ViewHolder vh=null;
			if(convertView==null){
				convertView=LayoutInflater.from(activity).inflate(R.layout.gridview_item_date, null);
				vh=new ViewHolder();
				vh.date=(TextView) convertView.findViewById(R.id.text);
				convertView.setTag(vh);
			}
			String str=date[position];
			vh=(ViewHolder) convertView.getTag();
			vh.date.setText(str);
			return convertView;
		}
		class ViewHolder{
			TextView date;
		}
}
